import java.util.Scanner;

public class TestClass extends Music {
    static Music[]music=new Music[10];
    static{
        music[5]=new User("小明","123456");
        music[2]=new Adminstrator("老大","123456");
    }

    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        for (int i = 0; i <music.length ; i++) {
            if (music[i]!=null){
                music[i].show();
            }
        }
        System.out.println("请选择：1、用户登录 2、用户注册 3、管理员登录 " );
        int num=input.nextInt();
        switch (num){
            case 1:
                System.out.println("请输入用户名");
                String name=input.next();
                System.out.println("请输入密码");
                String password=input.next();
                int index=-1;
                for (int i=0;i<music.length;i++){
                    if (music[i]!=null){
                        if (name.equals(music[i].getName())&&password.equals(music[i].getPassword())){
                            System.out.println("登录成功");
                            index=0;
                            break;
                        }
                        else {
                            System.out.println("用户名和密码不匹配");
                        }}
                }
                break;

            case 2:
                User m=new User();
                System.out.println("请设置用户名");
                name=input.next();
                m.setName(name);
                System.out.println("请设置密码");
                 password=input.next();
                 m.setPassword(password);
                for (int i = 0; i <music.length ; i++) {
                    if (music[i]==null){
                       music[i]=m;
                       break;
                    }
                    else {
                           continue;

                    }
                }
                System.out.println("添加成功");
                m.show();
                break;
            case 3:
                System.out.println("请输入管理员姓名");
                name=input.next();
                System.out.println("请输入密码");
                 password=input.next();
                index=-1;
                for (int i=0;i<music.length;i++){
                    if (music[i]!=null){
                        if (name.equals(music[i].getName())&&password.equals(music[i].getPassword())){
                            System.out.println("登录成功");
                            index=0;
                            break;
                        }
                        else {
                            System.out.println("用户名和密码不匹配");
                        }}
                }
                break;

        }
        }
}
